package Java攻略._5_流式操作_lambda表达式与方法_引用的相关问题._3_随机数流;

import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;

public class _7_生成随机数流 {

    public static void main(String[] args) {

        Random random = new Random();
        random.ints(5)
                .sorted()
                .forEach(System.out::println);

        random.doubles(5,0,0.5)
                .sorted()
                .forEach(System.out::println);

        List<Long> collect = random.longs(5)
                .boxed()
                .sorted()
                .collect(Collectors.toList());
        System.out.println(collect);

        LinkedList<Object> collect1 = random.ints(5, 10, 20)
                .sorted()
                .collect(
                        LinkedList::new,
                        LinkedList::add,
                        LinkedList::addAll
                );
        System.out.println(collect1);
    }
}
